/*
 * Button.cpp
 *
 *  Created on: 19.04.2011
 */

#include "Button.h"

Button::Button(int pin)
{
	buttonPin = pin;
	lastButtonState = LOW;
	lastDebounceTime = 0;
	debounceDelay = 75; 
}

int Button::getKey()
{
	reading = digitalRead(buttonPin);
	if (reading != lastButtonState)
	{
		lastDebounceTime = millis();
	}
	if ((millis() - lastDebounceTime) > debounceDelay) buttonState = reading;
	lastButtonState = reading;
	return buttonState;
}
